#include <iostream>
#include <pthread.h>
#include <unistd.h>

void *routine(void *arg)
{
    int cnt = 10;
    while (cnt--)
    {
        std::cout << "thread id: " << arg << std::endl;
        sleep(1);
    }
    return (void*)10;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, routine, (void *)"thread - 1");
    
    int cnt = 5;
    while (cnt--)
    {
        std::cout << "main thread" << std::endl;
        sleep(1);
    }

    void* ret;
    pthread_join(tid, &ret);

    return 0;
}